package com.xliu.csopenproject.pim_server.result;

public class Result<T> {
    private final int code;
    private final String msg;
    private final T data;

    private final static int SUCCESS = 0;
    private final static int FAILED = 1;

    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result<Void> success() {
        return new Result<>(SUCCESS, null, null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(SUCCESS, null, data);
    }
    
    public static Result<Void> failed(String msg) {
        return new Result<>(FAILED, msg, null);
    }
}
